﻿using System;
using StackExchange.Redis;

namespace StackExchangeRedisTest
{
    public class RedisManager
    {
        private static ConnectionMultiplexer _redis;
        private static readonly object _locker = new object();

        
        public static ConnectionMultiplexer Manager
        {
            get
            {
                if (_redis == null)
                {
                    lock (_locker)
                    {
                        if (_redis != null)
                        {
                            return _redis;
                        }

                        _redis = GetManager();
                        return _redis;
                    }
                }

                return _redis;
            }
        }

        private static ConnectionMultiplexer GetManager()
        {
            return ConnectionMultiplexer.Connect("127.0.0.1:6379,allowadmin=true");
        }
    }
}
